/*
分享界面
*/
var confige = require("confige");
cc.Class({
    extends: cc.Component,

    properties: {
        parent:{
            default:null,
            type:cc.Node
        },
        isInit:false,
    },

    onLoad: function () {

    },

    onInit:function(){
        this.shareBtn1 = this.node.getChildByName("btnShareSession").getComponent("cc.Button");
        this.shareBtn2 = this.node.getChildByName("btnShareTimeline").getComponent("cc.Button");
        this.isInit = true;
    },

    onBtnWXShare:function(event, customEventData){
        cc.log("fuck weixin share!!!!!!!!");
        this.shareBtn1.interactable = false;
        this.shareBtn2.interactable = false;
        var index = parseInt(customEventData);
        if(index == 0){
            cc.log("分享给好友");
            if(confige.curUsePlatform == 1)
            {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "WXShare", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V", confige.wxAppInfo.shareTitle, confige.wxAppInfo.shareDes, confige.wxAppInfo.shareURL, 0);
            }else if(confige.curUsePlatform == 2){
                jsb.reflection.callStaticMethod("JSCallOC", "WXShareTitle:andDes:andUrl:andType:",confige.wxAppInfo.shareTitle, confige.wxAppInfo.shareDes, confige.wxAppInfo.shareURL, 0);
            }
        }else if(index == 1){
            cc.log("分享到朋友圈");
            if(confige.curUsePlatform == 1)
            {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "WXShare", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V", confige.wxAppInfo.shareTitle, confige.wxAppInfo.shareDes, confige.wxAppInfo.shareURL, 1);
            }else if(confige.curUsePlatform == 2){
                jsb.reflection.callStaticMethod("JSCallOC", "WXShareTitle:andDes:andUrl:andType:",confige.wxAppInfo.shareTitle, confige.wxAppInfo.shareDes, confige.wxAppInfo.shareURL, 1);
            }
        }
        this.node.active = false;
        cc.log("weixin share call end");
    },

    showOrHideShareLayer:function(event, customEventData){
        var index = parseInt(customEventData);
        if(index == 0)
            this.node.active = false;
        else if(index == 1)
            this.node.active = true;
    },

    showLayer:function(){
        if(this.isInit == false)
            this.onInit();
        this.node.active = true;
    },

    hideLayer:function(){
        this.node.active = false;
    },
});
